package com.stein.mentalarithmetic;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

public class TestxAddy_4 extends Test234Add334 {

	public TestxAddy_4(Skin skin) {
		super(skin);
	}
	@Override
	protected void nextTest() {
		x = MathUtils.random(100, 9999);
		y =  MathUtils.random(100, 9999);
		String question = String.format(quesion, new Object[]{x,y});
		questionLabel.setText(question);
		re =   "   "+x+"\n"
				+ "+ "+y+"\n"
				+ "--------";
		resultLabel.setText(re);
	}
	@Override
	protected void showResult() {
		//re+"\n()" 
		String sy = y+"";
		int w = sy.length();
		int iw[] = new int [w];
		//1234
		result_q=re;
		result_q+="\n("+x+"+";
		for (int i = 0; i < iw.length; i++) {
			int tmp = (int) Math.pow(10, w-i-1);
			int t = tmp*(Integer.valueOf(sy.charAt(i)-'0').intValue());
			iw[i]=t;
			result_q+=iw[i];
			if(i!=iw.length-1){
				result_q+="+";
			}
		}
		
		result_q+=")\n="+(x+y);
		resultLabel.setText(result_q);
	}
	@Override
	protected void setName() {
		this.name = TestxAddy_4.class.getSimpleName();
	}
}
